home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / Source, The - Issue 1 (1993)(Epsilon)[WB].zip / Source, The - Issue 1 (1993)(Epsilon)[WB].adf / Utilities / IFFConverters / brush2asm.lha / b2a.asm < prev    next >
Assembly Source File  |  1990-12-15  |  21KB  |  712 lines

  1. ******************************************************************************
  2.  
  3. *  Program copyright Daniel Epp  March 1989
  4.  
  5. *  This program may be freely distributed as long as no charge is made for
  6. *  it.
  7. *  And the accompanying doc file remain with it.
  8.  
  9. *  B2A a program to convert IFF brush files to Assembler image data
  10.  
  11. *  You use this program at your OWN RISK no warrany of any kind is given!
  12. ******************************************************************************
  13.  
  14. * History
  15. * 04/11/89 fixed bug did not release all memory on exit D.Epp
  16. * 04/11/89 fixed bug Crashed system if there was a write error D.Epp
  17. ****************************************************************************
  18.  
  19.  
  20.    INCLUDE  "exec/types.i"
  21.    INCLUDE "exec/nodes.i"
  22.    INCLUDE "exec/libraries.i"
  23.    INCLUDE "libraries/dos.i"
  24.    INCLUDE "exec.asm"
  25.    INCLUDE "nMacros.asm"
  26.  
  27.  
  28.  
  29.  
  30.    XREF _AbsExecBase
  31.    XREF _LVOAllocMem
  32.    XREF _LVOFreeMem
  33.    XREF _LVOOpenLibrary
  34.    XREF _LVOCloseLibrary
  35.    XREF _LVOInput
  36.    XREF _LVOOutput
  37.    XREF _LVOIoErr
  38.    XREF _LVODeleteFile
  39.    XREF _LVOOpen
  40.    XREF _LVOClose
  41.    XREF _LVOSeek
  42.    XREF _LVORead
  43.    XREF _LVOWrite
  44.  
  45.  
  46.  
  47. ExecBase  EQU  $4
  48.  
  49.  
  50. WriteFile MACRO
  51.    move.l \1,d1         ;filename to write
  52.    move.l \2,d2         ;Buffer to write from
  53.    move.l \3,d3         ;number of chars to write
  54.    move.l   DosBase,a6
  55.    jsr    _LVOWrite(a6) ;write 'em
  56.    ENDM
  57.  
  58. ReadFile MACRO
  59.    move.l \1,d1         ;File to read
  60.    move.l \2,d2         ;Buffer to Store data
  61.    move.l \3,d3         ;maximum number of chars to read
  62.    move.l   DosBase,a6
  63.    jsr    _LVORead(a6)  ;read 'em
  64.    ENDM
  65.  
  66. *---------------------------------------------------------------------------
  67.  
  68.    move.l   a7,saveSP
  69.    move.l   _AbsExecBase,a6   ;find library address
  70.    move.l   #DOS_Name,a1      ;pass string containing name
  71.    clr.l    d0
  72.    jsr      _LVOOpenLibrary(a6)
  73.    move.l   d0,DosBase         ;a6 holds DOS library pointer from now on
  74.    beq      Abort             ;if d0=0 Abort
  75.    move.l   d0,a6
  76.    jsr      _LVOInput(a6)     ;get input file handle, already open
  77.    move.l   d0,StdIn          ;hang on to it
  78.    beq      Abort             ;Abort if can't find
  79.    jsr      _LVOOutput(a6)    ;get output file handle, if already open
  80.    move.l   d0,StdOut         ;hang on to it
  81.    beq      Abort             ;Abort if can't
  82.  
  83.    WriteFile StdOut,#gr_String,#gr_Len
  84.  
  85. GetFName:
  86.    WriteFile StdOut,#FName_Prompt,#Prompt_Len
  87.    ReadFile StdIn,#inFname,#80
  88.    cmpi.b   #32,inFname
  89.    bcs      Abort              ;quit on null string
  90.    move.l   #inFname,a0        ;name of in file
  91.    clr.b    -1(a0,d0.L)        ;null terminate it
  92.  
  93.    WriteFile StdOut,#OutName_Prompt,#Prompt_Len1
  94.    ReadFile StdIn,#outFname,#80
  95.    cmpi.b   #32,outFname
  96.    bcs      Err_Args           ;quit on null string
  97.    move.l   #outFname,a0       ;address of name of out file (could use Lea)
  98.    clr.b    -1(a0,d0.L)        ;null terminate it
  99.  
  100.    WriteFile StdOut,#Ctab_Prompt,#ctab_Len
  101.    ReadFile StdIn,#cmap,#80
  102.    cmpi.b   #32,cmap
  103.    bcs      1$                 ;not equal null do Colortable
  104.    move.b   #1,doCtab          ;set flag
  105. 1$
  106.    move.l   #inFname,d1       ;name of file
  107.    move.l   #MODE_OLDFILE,d2  ;set access mode
  108.    jsr      _LVOOpen(a6)      ;open file
  109.    lea      bm_Struct,a5      ;address of Bit Map Buffer
  110.    move.l   d0,pfhPic
  111.    bne      Read_Ifile          ;did we get one?
  112. *--------------------- All Error Msg's Are Here --------------------------*
  113. Error
  114.    WriteFile StdOut,#NotFound,#NotFoundLen ;express regrets could'nt open
  115.    bra      GetFName          ;try again
  116. ErrorILBM
  117.    WriteFile StdOut,#NotILBM,#Err_Len
  118.    bra      GetFName
  119. Err_Args
  120.    WriteFile StdOut,#NoInOutFile,#Err_InOut
  121.    bra      Abort
  122. ErrorMem
  123.    WriteFile StdOut,#NoMem,#Err_LenM
  124.    bra      Abort
  125. UknComp
  126.    WriteFile StdOut,#UknCompr,#Err_LenC
  127. WriteError                           ;will only get here from 2 places
  128.    jsr      _LVOIoErr(a6)
  129.    move.l   d0,IoError
  130.    move.l   Struct_fh,d1
  131.    jsr      _LVOClose(a6)
  132.    move.l   #0,Struct_fh
  133.    move.l   #outFname,d1
  134.    jsr      _LVODeleteFile(a6)
  135.    WriteFile StdOut,#WrErr,#Err_LenW
  136.    bra      Abort                    ;try to exit gracefully
  137. Read_Ifile
  138.    ReadFile pfhPic,#chunkBuff,#12
  139.    cmp.l    #'FORM',chunkType
  140.    bne      ErrorILBM
  141.  
  142.    cmp.l    #'ILBM',chunkSubType
  143.    bne      ErrorILBM
  144.  
  145. ReadILBM
  146.    ReadFile pfhPic,#chunkBuff,#8
  147.  
  148. CkBMHD
  149.    move.l   chunkType,d0
  150.    cmp.l    #'BMHD',d0
  151.    bne      CkCMAP
  152.  
  153.    move.l  a5,d2                   ;a5 contains address of bmhd buffer
  154.    ReadFile pfhPic,d2,#bmhd_SIZEOF
  155.    bra      ReadILBM
  156.  
  157. CkCMAP
  158.    cmp.l    #'CMAP',d0
  159.    bne      CkCAMG
  160.    move.l   chunkLen,d4
  161.    divu     #3,d4
  162.    move.w   d4,ccoMap
  163.    subq     #1,d4
  164.    lea.l    cmap,a3
  165.    lea      chunkLen+1,a4
  166. 1$
  167.    ReadFile pfhPic,#chunkLen+1,#3   ;read r,g,b values
  168.    moveq    #2,d5                   ;rgb counter
  169.    move.l   a4,a2                   ;reset a2 to Address of chunkLen
  170. 2$
  171.    move.b   (a2)+,d0                ;get rgb value
  172.    lsr.w    #4,d0                   ;need upper nibble of byte
  173.    moveq    #1,d6                   ;counter for byte dec conversion
  174.    moveq    #0,d7
  175. 3$
  176.    divu     #10,d0                  ;just converting binary
  177.    swap     d0
  178.    move.b   d0,d1
  179. 4$
  180.    add.b    #'0',d1
  181.    clr.w    d0
  182.    swap     d0                       ;to ASCII decimal
  183.    tst.w    d0
  184.    beq      5$
  185.    move.b   d1,d7                    ;if here number is 2 digits (ie 10-15)
  186.                                      ;so save d1 for later
  187.    dbra     d6,3$                    ;go back & finish the number
  188.  
  189. 5$
  190.    move.b   d1,(a3)+                 ;store the result
  191.    tst.b    d7
  192.    beq      6$
  193.    move.b   d7,(a3)+
  194. 6$
  195.    move.b   #',',(a3)+
  196.    dbra     d5,2$
  197.    move.b   #0,-1(a3)                 ;null terminate
  198.    dbra     d4,1$                     ;do again nColors-1
  199.    bra      ReadILBM
  200.  
  201. CkCAMG
  202.    cmp.l    #'CAMG',d0
  203.    bne      CkBODY
  204.    ReadFile pfhPic,#chunkSubType,#4
  205.    move.w   chunkSubType+2,TossIt
  206.    bra      ReadILBM
  207.  
  208. CkBODY
  209.    cmp.l    #'BODY',d0
  210.    beq      Continue
  211.  
  212. DontNeed
  213.    move.l   pfhPic,d1
  214.    move.l   chunkLen,d2
  215.    moveq    #OFFSET_CURRENT,d3
  216.    jsr      _LVOSeek(a6)
  217.    bra      ReadILBM
  218.  
  219. Continue
  220.    move.l   chunkLen,d7                ;length in bytes of Body
  221.    move.l   a5,a3                      ;address of bmhd Buffer
  222.  
  223.    cmp.b    #2,bmhd_compression(a3)
  224.    bge      UknComp
  225.    move.l   d7,d0                      ;allocate memory for file
  226.    move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  227.    move.l   ExecBase,a6
  228.    jsr      _LVOAllocMem(a6)
  229.    move.l   d0,picBuff
  230.    beq      ErrorMem
  231.  
  232. *------------ Figure out approx memory need for out file ---*
  233.    move.w   bmhd_w(a3),d3           ;width of image
  234.    add.w    #16,d3                  ;plus 16
  235.    bclr     #0,d3                   ;make sure even number
  236.    moveq    #0,d0
  237.    move.w   bmhd_h(a3),d0           ;height of image
  238.    addq     #1,d0
  239.    mulu     d0,d3                   ;width*height
  240.    lsr.l    #3,d3                   ;divided by 8 (convert to bytes)
  241.    btst     #0,d3
  242.    beq      Ok1
  243.    addq     #2,d3                   ;make even number of bytes
  244.    bclr     #0,d3
  245. Ok1
  246.                                  ;1 binary byte = 2 ASCII bytes
  247.    lsl.l    #1,d3                ;*2 for ASCII conversion
  248.    move.l   d3,bytes_per_Plane   ;save for later
  249.  
  250.    moveq    #0,d2
  251.    move.b   bmhd_nPlanes(a3),d2
  252.    subq     #1,d2                   ;-1 for dbra loop
  253.    lea.l    PlanePtr,a2             ;Array for memory for Planes Ptr's
  254.  
  255. MoreMem                          ;Allocate memory for n Planes
  256.    move.l   d3,d0
  257.    move.l   #MEMF_CLEAR!MEMF_PUBLIC,d1
  258.    jsr      _LVOAllocMem(a6)
  259.    move.l   d0,(a2)+
  260.    beq      ErrorMem
  261.    dbra     d2,MoreMem
  262.  
  263.    ReadFile pfhPic,picBuff,d7
  264.  
  265. Decomp
  266.    lea.l    PlanePtr,a6                 ;ptr to Plane 1 buffer
  267.    cmp.b    #1,bmhd_masking(a3)
  268.    bne      10$
  269.    moveq    #0,d0
  270.    move.b   bmhd_nPlanes(a3),d0
  271.    lsl.w    #2,d0
  272.    move.l   #$FE0000,0(a6,d0.w)
  273.    addq.b   #1,bmhd_nPlanes(a3)
  274. 10$
  275.    moveq    #0,d6
  276.    move.w   bmhd_w(a3),d6  ;width of image
  277.    divu     #8,d6          ;divided by 8 = bytes per row
  278.    move.l   d6,d5
  279.    swap     d5             ;check for remainder from divide
  280.    tst.w    d5
  281.    beq      11$            ;if yes
  282.    add.w    #2,d6          ;add 2 bytes
  283.    bclr     #0,d6          ;make sure d6 is even number
  284. 11$
  285.    move.l   picBuff,a0     ;address of picture file
  286.    move.w   bmhd_h(a3),d4  ;# of rows
  287.    subq.w   #1,d4          ;# of rows -1
  288.    moveq    #0,d3
  289. 1$
  290.    moveq    #0,d5
  291.    move.b   bmhd_nPlanes(a3),d5      ;# of planes in picture
  292.    move.l   a6,a2                    ;restore plane ptr to 1st
  293. 2$
  294.    dbra     d5,3$                    ;loop each plane convert 1 row
  295.    move.w   d6,d1                    ;d6 is offset in to file
  296.    lsl.w    #1,d1                    ;*2 because were moving words after
  297.    add.w    d1,d3                    ;conversion
  298.    dbra     d4,1$                    ;decrement rows and do it again for all
  299.                                      ;rows
  300.    bra      MakeFile                 ;done go write the converted file
  301. 3$
  302.    move.l   (a2)+,a1
  303.    add.w    d3,a1
  304. 35$
  305.    move.w   d6,d2                     ;put bytes per row in d2
  306.    tst.b    bmhd_compression(a3)      ;is file compressed?
  307.    bne      50$                       ;branch if <> 0 compressed = 1
  308.    subq     #1,d2                     ;if were here
  309. 4$                                    ;row not compressed
  310.    move.b   (a0)+,d0                  ;so move bytes literally
  311.    bsr      bin2Hex                   ;convert to ASCII
  312.    move.w   d0,(a1)+                  ;store in Plane (n) buffer
  313.    dbra     d2,4$                     ;do d2 times (1 row)
  314.    bra      2$
  315. 50$                                   ;if here row is compressed
  316.    tst.w    d2                        ;d2 = bytes_per_row
  317.    ble      2$                        ;if 0 this row done
  318.    moveq    #0,d1
  319. 51$
  320.    move.b   (a0)+,d1                  ;d1 contains #bytes to replicate if -
  321.    bmi      53$                       ;if not - do d1 row of bytes
  322.    sub.w    d1,d2
  323.    subq.w   #1,d2
  324. 52$
  325.    move.b   (a0)+,d0
  326.    bsr      bin2Hex
  327.    move.w   d0,(a1)+
  328.    dbra     d1,52$
  329.    bra      50$
  330. 53$
  331.    cmp.b    #128,d1                     ;byte was negative so d1
  332.    beq      50$                         ;is # of bytes to replicate
  333.    neg.b    d1                          ;change to plus value
  334.    sub.w    d1,d2
  335.    subq.w   #1,d2
  336.    move.b   (a0)+,d0                    ;replicate byte in d0 d1 times
  337.    bsr      bin2Hex
  338. 54$
  339.    move.w   d0,(a1)+
  340.    dbra     d1,54$
  341.    bra      50$
  342. *------------------------- Convert binary to ASCII ----------------------*
  343. bin2Hex
  344.    movem.l  d1-d2/a0-a1,-(a7)       ;save registers used
  345.    lea      HexTab,a1               ;Hex digits
  346.    lea      Hdigit,a0               ;longword to store results
  347.    adda.l   #2,a0                   ;word operation for this use
  348.    move.l   #1,d1                   ;loop twice
  349. hLoop
  350.    move.l   d0,d2                   ;d0 contains byte to convert
  351.    andi.l   #15,d2                  ;mask off all but lower nibble
  352.    move.b   0(a1,d2),-(a0)          ;move value from hex table
  353.    lsr.l    #4,d0                   ;get next nibble
  354.    dbra     d1,hLoop
  355.    move.w   (a0)+,d0                ;put result back in d0
  356.    movem.l  (a7)+,d1-d2/a0-a1
  357.    rts
  358.  
  359. MakeFile
  360.    move.l   a5,a3               ;Get info for Image Structure
  361.    move.w   bmhd_x(a3),d0
  362.    lea      image_left,a0
  363.    bsr      BintoDec
  364.    move.w   bmhd_y(a3),d0
  365.    lea      image_top,a0
  366.    bsr      BintoDec
  367.    move.w   bmhd_w(a3),d0
  368.    lea      image_w,a0
  369.    bsr      BintoDec
  370.    move.w   bmhd_h(a3),d0
  371.    lea      image_h,a0
  372.    bsr      BintoDec
  373.    move.b   bmhd_nPlanes(a3),d0
  374.    lea      image_nPlane,a0
  375.    bsr      BintoDec
  376.    move.l   DosBase,a6
  377.    move.l   #outFname,d1          ;name of file
  378.    move.l   #MODE_NEWFILE,d2      ;set access mode
  379.    jsr      _LVOOpen(a6)          ;open file
  380.  
  381.    move.l   d0,Struct_fh          ;d0 contains our file handle
  382.    beq      CloseFil              ;didn't get one? Panic
  383.  
  384.    lea      image_left,a0         ;fill Image Structure with values
  385.    lea      im_Structure,a1       ;obtained above
  386.    moveq    #4,d2                 ;5 values (x,y,width,height,depth)
  387.    bsr      fill_Str
  388.    move.b   #' ',-1(a1)           ;removes last comma from fill_Str routine
  389.  
  390.    WriteFile Struct_fh,#im_Structure,#im_Send   ;write the image structure
  391.  
  392. do_Data
  393.    lea      PlanePtr,a0
  394.    moveq    #0,d3
  395.    move.b   bmhd_nPlanes(a3),d3
  396.    subq.b   #1,d3
  397. 1$
  398.    move.l   (a0)+,a1             ;ptr's to n planes of data
  399.    move.l   bytes_per_Plane,d2
  400.    lsr.l    #2,d2                ;convert bytes to longwords
  401.    lsr.l    #3,d2                ;d2 longwords / 8 per row
  402.    subq     #1,d2                ;-1 for dbra counter loop
  403. 10$
  404.    moveq    #7,d0                ;n entries-1 per row
  405.    lea      formatBuff,a2        ;buffer for formatting output
  406. 20$
  407.    move.w      #'  ',(a2)+
  408.    move.l      #' dc.',(a2)+
  409.    move.l      #'w  $',(a2)+
  410.    cmp.w       #7,d0             ;1st time thru each line don't put a ,$
  411.    beq         31$
  412. 30$
  413.    move.w      #',$',(a2)+       ;append ,$
  414. 31$
  415.    move.l      (a1)+,(a2)+       ;takes long move to move ASCII word '0000'
  416.    beq         34$               ;no more in this plane?
  417.    dbra        d0,30$            ;loop thru 1 line at a time
  418. 33$
  419.    movem.l     d2-d3/a0-a2,-(a7)
  420.    WriteFile   Struct_fh,#formatBuff,#57   ;write the line
  421.    movem.l     (a7)+,d2-d3/a0-a2
  422.    tst.l       d0
  423.    bmi         WriteError
  424.    dbra        d2,10$                      ;loop thru 1 plane at a time
  425.  
  426.    movem.l     d2-d3/a0-a2,-(a7)
  427.    WriteFile   Struct_fh,#BlankLine,#57    ;insert a blank line
  428.    movem.l     (a7)+,d2-d3/a0-a2
  429.    tst.l       d0
  430.    bmi         WriteError
  431.    dbra        d3,1$                       ;do next plane
  432.    tst.b       doCtab                      ;Did user want Palette info?
  433.    beq         Abort                         ;=0? Close up shop were done!
  434.    bsr         DoColorDATA                 ;if so Go do it
  435. 36$
  436.    bra         Abort                       ;Were Done!
  437. *--------------- This is for last line padding each plane ------------*
  438. 34$
  439.    subq.l      #6,a2                ;get rid of extra characters
  440.    moveq       #0,d2                ;set line counter to 0
  441. 35$
  442.    move.w      #'  ',(a2)+          ;pad out with spaces
  443.    move.l      #'    ',(a2)+
  444.    dbra        d0,35$               ;amount left in d0
  445.    bra         33$                  ;go back and write the line
  446.  
  447. fill_Str
  448.    add.w    #10,a1                  ;don't overwrite dc.w in buffer
  449. 1$
  450.    moveq    #7,d1                   ;check 8 bytes each
  451. 10$
  452.    move.b   (a0)+,d0
  453.    beq      12$                     ;if not 0 put value
  454. 11$
  455.    move.b   d0,(a1)+                ;in buffer and
  456. 12$
  457.    dbra     d1,10$
  458.    move.b   #',',(a1)+              ;append comma
  459.    dbra     d2,1$
  460.    rts
  461.  
  462. DoColorDATA
  463.    WriteFile   Struct_fh,#ColorTabName,#ct_Len  ;color table label
  464.    move.w      ccoMap,d5                        ;no of colors
  465.    subq        #1,d5                            ;-1
  466.    lea         cmap,a4                          ;address of colortable
  467. 40$
  468.    lea         ColorData+10,a3
  469.    moveq       #0,d3
  470. 41$
  471.    addq        #1,d3                         ;# of bytes moved
  472.    move.b      (a4)+,(a3)+                   ;copy rgb to format buffer
  473.    bne         41$                           ;till hit 0 byte
  474.    move.b      #10,-1(a3)                    ;put linefeed char
  475.    add.w        #10,d3                       ;add 10 char for spaces & dc.w
  476.    WriteFile   Struct_fh,#ColorData,d3       ;write the line
  477.    tst.l       d0
  478.    bmi         WriteError
  479.    dbra        d5,40$                        ;do nColors-1 times
  480.    rts
  481. *--------------------- Convert Bin Decimal Number --------------------*
  482. *  Enter with number to convert in d0                                 *
  483. *  Ptr to 8 byte buffer in a0
  484. *  Handles only 4 digit ASCII conversion                              *
  485. *  The amount that fits one longword! (thats all I needed)            *
  486. *---------------------------------------------------------------------*
  487. BintoDec
  488.    moveq    #5,d1
  489.    moveq    #0,d2
  490. dLoop
  491.    divu     #10,d0          ;divide the number by 10 (base ten)
  492.    swap     d0              ;the remainder is the number we need
  493.    move.b   d0,d2        ;remainder is in high order of word
  494.    add.b    #'0',d2       ;add 30 to result to make it ASCII
  495.    ror.l    #8,d2
  496.    clr.w    d0
  497.    swap     d0
  498.    tst      d0              ;If d0 not 0 go divide again
  499.    beq      nMoreDigits
  500.    dbra     d1,dLoop
  501.    bra      ConvertDone
  502. nMoreDigits
  503.    ;move.b   #' ',-(a0)      ;pad out unused decimal places with spaces
  504.    ;dbra     d1,nMoreDigits
  505. ConvertDone
  506.     move.l  d2,(a0)
  507.     rts
  508.  
  509. Write
  510.    move.l   DosBase,a6
  511.    jsr      _LVOWrite(a6)
  512.    rts
  513. Read
  514.    move.l   DosBase,a6
  515.    jsr      _LVORead(a6)
  516.    rts
  517.  
  518. Abort
  519. CloseFil
  520.    move.l   saveSP,sp
  521.    move.l   DosBase,a6
  522.    move.l   pfhPic,d1
  523.    beq      3$
  524.    jsr      _LVOClose(a6)
  525. 3$
  526.    move.l   Struct_fh,d1
  527.    beq      4$
  528.    jsr      _LVOClose(a6)
  529. 4$
  530.  
  531.    tst.l    picBuff
  532.    beq      10$
  533.    move.l   picBuff,a1
  534.    move.l   d7,d0
  535.    move.l   ExecBase,a6
  536.    jsr      _LVOFreeMem(a6)
  537. 10$
  538.    lea.l    PlanePtr,a4
  539. 11$
  540.    move.l   (a4)+,d0
  541.    beq      20$
  542.    move.l   d0,a1
  543.    move.l   bytes_per_Plane,d0
  544.    move.l   ExecBase,a6
  545.    jsr      _LVOFreeMem(a6)
  546.    bra      11$
  547. 20$
  548.    move.l   DosBase,d0
  549.    beq      30$
  550.    move.l   d0,a1
  551.    move.l   ExecBase,a6
  552.    jsr      _LVOCloseLibrary(a6)
  553. 30$
  554.    move.l   IoError,d0
  555.    rts
  556.  
  557.    SECTION data,DATA
  558. * ===========================================================================
  559. * IFF BitMap header structure (BMHD)
  560.    STRUCTURE BitMapHeader,0
  561.       UWORD bmhd_w
  562.       UWORD bmhd_h
  563.       WORD  bmhd_x
  564.       WORD  bmhd_y
  565.       UBYTE bmhd_nPlanes
  566.       UBYTE bmhd_masking
  567.       UBYTE bmhd_compression
  568.       UBYTE bmhd_pad1
  569.       UWORD bmhd_transparentColor
  570.       UBYTE bmhd_xAspect
  571.       UBYTE bmhd_yAspect
  572.       WORD  bmhd_pageWidth
  573.       WORD  bmhd_pageHeight
  574.    LABEL bmhd_SIZEOF
  575.       cnop 0,2
  576. * ===========================================================================
  577.  
  578.  
  579. DOS_Name:
  580.    dc.b     'dos.library',0   ;any version
  581.    cnop 0,2
  582. gr_String
  583.    dc.b  $9b,'3;33;42m'
  584.    dc.b  ' Brush to Asm',$9b,'0;33;42m V 1.01 Copyright © 1989 by Dan Epp '
  585.    dc.b  $9b,'0;31;40m',13,10
  586. gr_Len equ *-gr_String
  587.    cnop 0,2
  588.  
  589. FName_Prompt:
  590.    dc.b  10,'Brush File to Convert: ',0
  591. Prompt_Len EQU    *-FName_Prompt
  592.    cnop 0,2
  593.  
  594. OutName_Prompt
  595.    dc.b  'Name of Out File: ',0
  596. Prompt_Len1 EQU    *-OutName_Prompt
  597.    cnop 0,2
  598.  
  599. Ctab_Prompt
  600.    dc.b  'Do you Want Color Info? Return = None: ',0
  601. ctab_Len    equ   *-Ctab_Prompt
  602.    cnop 0,2
  603.  
  604. NotFound
  605.    dc.b     'Sorry, Could not Open File... Not Found? ',13,10
  606. NotFoundLen EQU   *-NotFound
  607.    cnop 0,2
  608.  
  609. NotILBM
  610.    dc.b     'File is not an IFF Brush File',13,10
  611. Err_Len     EQU *-NotILBM
  612.    cnop 0,2
  613.  
  614. NoMem
  615.    dc.b     'Could not Allocate Memory For Buffers!',10
  616. Err_LenM    EQU *-NoMem
  617.    cnop 0,2
  618.  
  619. UknCompr
  620.    dc.b     'Can not Read, Unknown Compression Used!',10
  621. Err_LenC    EQU *-UknCompr
  622.    cnop 0,2
  623. NoInOutFile
  624.    dc.b     'Must supply In and Out File Names!',10
  625. Err_InOut   equ  *-NoInOutFile
  626.    cnop 0,2
  627. WrErr
  628.    dc.b     10,'Write Error Occurred, File Removed',10
  629. Err_LenW  equ  *-WrErr
  630.    cnop 0,2
  631.  
  632. BlankLine
  633.    dc.b ';End of Plane                                           ',10
  634.    cnop 0,2
  635. bl_Len equ *-BlankLine
  636.  
  637. formatBuff
  638.    dc.b '                                                        ',10
  639. fm_Len equ *-formatBuff
  640.    cnop 0,2
  641.  
  642. saveSP      dc.l  0
  643. PlanePtr    dc.l  0,0,0,0,0,0,0,0      ;array for plane ptrs
  644. StdIn       dc.l  0
  645. StdOut      dc.l  0
  646. IoError     dc.l  0
  647. Struct_fh   dc.l  0    ;file handle for Output File
  648. pfhPic      dc.l  0    ;file Handle for Picture file
  649. picBuff     dc.l  0    ;ptr to Buffer for ILBM file
  650. DosBase     dc.l  0
  651.  
  652. bytes_per_Plane dc.l 0
  653.  
  654. chunkBuff
  655. chunkType    dc.l  0                  ;IFF chunk info read here
  656. chunkLen     dc.l  0
  657. chunkSubType dc.l  0
  658. fGotCMAP     dc.b  0
  659. doCtab       dc.b  0
  660.  
  661. image_left     dcb.b 8,0
  662. image_top      dcb.b 8,0
  663. image_w        dcb.b 8,0
  664. image_h        dcb.b 8,0
  665. image_nPlane   dcb.b 2,0
  666. image_dPtr     dcb.b 16,0
  667. image_planPick dcb.b 4,0
  668. image_pad      dcb.b 2,0
  669. image_Next     dcb.b 16,0
  670.  
  671. ColorTabName
  672.    dc.b  'ColorTable',10
  673. ct_Len   equ *-ColorTabName
  674. ColorData
  675.    dc.b  '   dc.w            '
  676. cd_Len   equ *-ColorData
  677.  
  678. im_Structure
  679.    dc.b '   dc.w                   ;left_edge,top_edge,width,height,depth ',10
  680. im_f1  equ *-im_Structure
  681.  
  682. im_data_Ptr
  683.    dc.b '   dc.l   0                ;Ptr to Image Data ',10
  684.  
  685. im_Plane_Pick
  686.    dc.b '   dc.b   3,0              ;PlanePick PlaneOff ',10
  687.  
  688. im_Ptr_Next
  689.    dc.b '   dc.l   0                ;Ptr to Next Image ',13,10
  690.    dc.b ';--------------------- Image Data --------------------',10
  691. im_Send equ *-im_Structure
  692.    cnop 0,2
  693.  
  694. HexTab dc.b '0123456789ABCDEF'
  695.    cnop 0,2
  696.  
  697. TossIt      dc.w 0
  698. ccoMap      dc.w 0
  699. Hdigit      dc.w 0
  700.  
  701.    SECTION BSS
  702. inFname    ds.b  80    ;Buffer for in file name
  703. outFname   ds.b  80    ;Buffer for out file name
  704. bm_Struct  ds.b  bmhd_SIZEOF
  705. cmap       ds.b  (32*4)
  706.  
  707.    END
  708.  
  709.  
  710.  
  711.  
  712.